<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head id="MyHead">
    <script src="/resources/Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="/resources/Scripts/jquery.easyui.min-1.3.5.js" type="text/javascript"></script>
        <script src="/resources/Scripts/jquery.datagrid.js" type="text/javascript"></script>
    <script src="/resources/Scripts/JScriptIndex.js" type="text/javascript"></script>
    <link href="/resources/Content/Default.css" rel="stylesheet" type="text/css" />
    <link href="/resources/Content/IndexStyle.css" rel="stylesheet" type="text/css" />

        <link href="/resources/Res/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
        <script src="/resources/Res/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <link href="/resources/Res/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <title>
	
    班级

</title>
     <script type="text/javascript" language="javascript">
         $(function () {
             $.extend($.fn.datagrid.methods, {
                 addToolbarItem: function (jq, items) {
                     return jq.each(function () {
                         var dpanel = $(this).datagrid('getPanel');
                         var toolbar = dpanel.children("div.datagrid-toolbar");
                         if (!toolbar.length) {
                             toolbar = $("<div class=\"datagrid-toolbar\"><table cellspacing=\"0\" cellpadding=\"0\"><tr></tr></table></div>").prependTo(dpanel);
                             $(this).datagrid('resize');
                         }
                         var tr = toolbar.find("tr");
                         for (var i = 0; i < items.length; i++) {
                             var btn = items[i];
                             if (btn == "-") {
                                 $("<td><div class=\"datagrid-btn-separator\"></div></td>").appendTo(tr);
                             } else {
                                 var td = $("<td></td>").appendTo(tr);
                                 var b = $("<a href=\"javascript:void(0)\"></a>").appendTo(td);
                                 b[0].onclick = eval(btn.handler || function () { });
                                 b.linkbutton($.extend({}, btn, {
                                     plain: true
                                 }));
                             }
                         }
                     });
                 },
                 removeToolbarItem: function (jq, param) {
                     return jq.each(function () {
                         var dpanel = $(this).datagrid('getPanel');
                         var toolbar = dpanel.children("div.datagrid-toolbar");
                         var cbtn = null;
                         if (typeof param == "number") {
                             cbtn = toolbar.find("td").eq(param).find('span.l-btn-text');
                         } else if (typeof param == "string") {
                             cbtn = toolbar.find("span.l-btn-text:contains('" + param + "')");
                         }
                         if (cbtn && cbtn.length > 0) {
                             cbtn.closest('td').remove();
                             cbtn = null;
                         }
                     });
                 }
             });
         });
    </script>
    
    
    <script type="text/javascript" language="javascript">
        $(function () {




            $('#flexigridData').datagrid({
                //title: '班级', //列表的标题
                iconCls: 'icon-site',
                width: '800',
                height: 'auto',
                nowrap: true,
                striped: true,
                collapsible: true,
                url: 'showClazz', //获取数据的url
                sortName: 'clazzId',
                sortOrder: 'desc',
                idField: 'clazzId',

                
                toolbar: [
                      	{
						    text: '创建',
						    iconCls: 'icon-add',
						    handler: function () {
						  	  flexiCreate();
						    }
						}
                      	 , {
                             text: '删除',
                             iconCls: 'icon-no',
                             handler: function () {
                                 flexiDelete();
                             }
                         }
                        , {
                            text: '编辑',
                            iconCls: 'icon-edit',
                            handler: function () {
                           	 flexiModify();
                            }
                        }
                     ],
                columns: [[

                    { field: 'clazzId', title: '<label for="SL_ID">班别编号</label>', width: 80, sortable: true }
					,{ field: 'clazzName', title: '<label for="SL_Name">班别名称</label>', width: 160, sortable: true }

                   /*  , { field: 'JihuaXueshiNum', title: '<label for="JihuaXueshiNum">训练场计时</label>', width: 80, sortable: true }
                    , { field: 'S_kscjs', title: '<label for="S_kscjs">考试场计时</label>', width: 80, sortable: true }
                    , { field: 'JiShiPrice', title: '<label for="JiShiPrice">训练场单价</label>', width: 80, sortable: true, formatter: function (value, rec) { return formatCurrency(value) }, align: 'right' }
                    , { field: 'BuShiPrice', title: '<label for="BuShiPrice">考试场单价</label>', width: 80, sortable: true, formatter: function (value, rec) { return formatCurrency(value) }, align: 'right' } */
                     , { field: 'licenseType', title: '<label for="CarType">准驾车型</label>', width: 80, sortable: true }
                    , { field: 'branchSchool', title: '<label for="fenxiaoID">所属分校</label>', width: 80,sortable:true}
                    /* , { field: 'classSort', title: '<label for="classSort">班别排序</label>', width: 80, sortable: true }
					, { field: 'SL_Teacher', title: '<label for="SL_Teacher">负责人</label>', width: 80 } */
					, { field: 'productName', title: '<label for="SL_SPIDOld">所属产品</label>', width: 120, sortable: true }
                  /*   , { field: 'classType', title: '<label for="classType">班别类型</label>', width: 80, sortable: true }
                     , { field: 'fukuanClass', title: '<label for="fukuanClass">付款类别</label>', width: 80, sortable: true }
                     , { field: 'BukaofeiWho', title: '<label for="BukaofeiWho">科一补考费承担方</label>', width: 90, sortable: true }
                     , { field: 'BukaofeiWho2', title: '<label for="BukaofeiWho2">科二补考费承担方</label>', width: 90, sortable: true }
                     , { field: 'BukaofeiWho3', title: '<label for="BukaofeiWho3">科三补考费承担方</label>', width: 90, sortable: true }
                     , { field: 'qianfei_is_k2', title: '科目二(分车)', width: 90, sortable: true }
                     , { field: 'qianfei_is_k3', title: '科目三(分车)', width: 90, sortable: true }
                     , { field: 'isBaokKem2', title: '报考科目二', width: 90, sortable: true }
                     , { field: 'zhaos_tic', title: '招生提成', width: 60, sortable: true, formatter: function (value, rec) { return formatCurrency(value) }, align: 'right' }
                     , { field: 'hege_tic', title: '合格提成', width: 60, sortable: true, formatter: function (value, rec) { return formatCurrency(value) }, align: 'right' }
                     , { field: 'xueshi_tic', title: '学时提成', width: 60, sortable: true, formatter: function (value, rec) { return formatCurrency(value) }, align: 'right' } */
                     , { field: 'clazzStatus', title: '<label for="State">状态</label>', width: 80, sortable: true }
				/* 	, { field: 'SL_SDATE', title: '<label for="SL_SDATE">开始日期</label>', width: 80, sortable: true
                    , formatter: function (value, rec) {
                        if (value) {
                            return dateConvert(value);
                        } 
                    } 
}
					, { field: 'SL_EDATE', title: '<label for="SL_EDATE">结束日期</label>', width: 80
                    , formatter: function (value, rec) {
                        if (value) {
                            return dateConvert(value);
                        } 
                    }
                } */
                ]],
                pagePosition: 'noth', 
                pagination: true,
                rownumbers: true

            });


            $("#flexigridData").datagrid({ toolbar: "#yesSearch" });

//            var parent = window.dialogArguments; //获取父页面
//            if (parent == "undefined" || parent == null) {
//                $(".l-btn.l-btn-plain:last").hide();
//            } else {
//                $(".l-btn.l-btn-plain").hide();
//                $(".datagrid-btn-separator").hide();
//                $(".l-btn.l-btn-plain:last").show();
//            }

            //如果列表页出现在弹出框中，则只显示查询和选择按钮 
           /*  var parent = window.dialogArguments; //获取父页面
            if (parent == "undefined" || parent == null) {
                //异步获取按钮
                var iframeid;

                var fs = window.parent.window.frames;
                for (var i = 0; i < fs.length; i++) {
                    if (window == fs[i]) {
                        var iframe = window.parent.document.getElementsByTagName("iframe")[i];
                        iframeid = iframe.id;

                    }
                }
                //关闭AJAX相应的缓存
                $.ajaxSetup({
                    cache: false
                });

                $.getJSON("Home/GetToolbar", { id: iframeid }, function (data) {
                    if (data == null) {
                        return;
                    }
                    $('#flexigridData').datagrid("addToolbarItem", data);

                });

            } else {
                //添加选择按钮
                $('#flexigridData').datagrid("addToolbarItem", [{ "text": "选择", "iconCls": "icon-ok", handler: function () { flexiSelect(); } }]);
            } */

        });

        //“查询”按钮，弹出查询框
        function flexiQuery() {
            $('#divQuery').dialog({          
                buttons: [{
                    text: '查询',
                    iconCls: 'icon-ok',
                    handler: function () {
                       //将查询条件按照分隔符拼接成字符串
                        /* var search = "";
                        $('#divQuery').find(":text,:selected,select,textarea,:hidden,:checked,:password").each(function () {
                            search = search + this.id + "&" + this.value + "^";
                        }); */
                        //执行查询                        
                        $('#flexigridData').datagrid('reload', { search: search });
                    }
                },
                     {
                         text: '取消',
                         iconCls: 'icon-cancel',
                         handler: function () {
                             $('#divQuery').dialog("close");
                         }
                     }]
            });
            $('#divQuery').dialog("open");
        };

        function FindData() {
          /*   var search = "";

            var fenxiaoID = $("#fenxiaoID").combobox("getValue");
            var chexingID = $("#chexingID").combobox("getValue");
            var SL_Name = $("#SL_Name").val();

            var SL_SDATE = $("#SL_SDATE").val();
            var SL_EDATE = $("#SL_EDATE").val();

            if (SL_SDATE != "") {
                search += "SL_SDATE&" + SL_SDATE + "^"
            }

            if (SL_EDATE != "") {
                search += "SL_EDATE&" + SL_EDATE + "^"
            }

            if (fenxiaoID != "") {
                search += "fenxiaoID&" + fenxiaoID + "^";
            }

            if (chexingID != "") {
                search += "CarType&" + chexingID + "^";
            }

            if (SL_Name != "") {
                search += "SL_Name&" + SL_Name + "^"
            }
 */



            //alert(search);
            //执行查询                        
            $('#flexigridData').datagrid('reload', { clazzName:$("#clazzName").val(),branchSchool:$("#branchSchool").combobox("getValue"),licenseType:$("#licenseType").combobox("getValue")  });
        }

        //“选择”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
        function flexiSelect() {

            var rows = $('#flexigridData').datagrid('getSelections');
            if (rows.length == 0) {
                $.messager.alert('操作提示', '请选择数据!', 'warning');
                return false;
            }

            var arr = [];
            for (var i = 0; i < rows.length; i++) {
                arr.push(rows[i].PK_ID);
            }
            arr.push("^");
            for (var i = 0; i < rows.length; i++) {
                arr.push(rows[i].SL_Name);
            }
            //主键列和显示列之间用 ^ 分割   每一项用 , 分割
            if (arr.length > 0) {//一条数据和多于一条
                returnParent(arr.join("&")); //每一项用 & 分割
            }
        }
        //导航到查看详细的按钮
        function getView() {

            var arr = $('#flexigridData').datagrid('getSelections');

            if (arr.length == 1) {
                window.location.href = "S_Class/Details/" + arr[0].PK_ID;
               
            } else {
                $.messager.alert('操作提示', '请选择一条数据!', 'warning');
            }
            return false;
        }
        //导航到创建的按钮
        function flexiCreate() {

            window.location.href = "toCreate";
            return false;
        }
        //导航到修改的按钮
        function flexiModify() {

            var arr = $('#flexigridData').datagrid('getSelections');

            if (arr.length == 1) {
                window.location.href = "toEdit?clazzId=" + arr[0].clazzId;

            } else {
                $.messager.alert('操作提示', '请选择一条数据!', 'warning');
            }
            return false;

        };
        //删除的按钮
        function flexiDelete() {

            var rows = $('#flexigridData').datagrid('getSelections');
            if (rows.length == 0) {
                $.messager.alert('操作提示', '请选择数据!', 'warning');
                return false;
            }

            var arr = [];
            for (var i = 0; i < rows.length; i++) {
                arr.push(rows[i].clazzId);
            }

            $.messager.confirm('操作提示', "确认删除这 " + arr.length + " 项吗？", function (r) {
                if (r) {
                    $.post("delClazz", { query: arr.join(",") }, function (data) {
                        if (data.res == "OK") {
                           //移除删除的数据
                            $("#flexigridData").datagrid("reload");
                            $("#flexigridData").datagrid("clearSelections");
                            $.messager.alert('操作提示', '删除成功!', 'info');
                        }
                        else {
                            if (res == "") {
                                $.messager.alert('操作提示', '删除失败!请查看该数据与其他模块下的信息的关联，或联系管理员。', 'info');
                            }
                            else {
                               $.messager.alert('操作提示', data.res, 'info');
                            }
                        }
                    });
                }
            });

        };

    </script>

    <script src="/resources/Res/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

      <base target = "_self">
</head>
<body class="easyui-layout" style="padding:3px;">
    <table id="flexigridData" fit="true">
    </table>
    


        <div id="yesSearch" style="padding:5px;height:auto; font-size:12px;">
        <div style=" height:23px; padding-bottom:6px;">
            班别名称：<input class="input-textbox" id="clazzName" style="width:100px" />
            &nbsp;所属分校：<select class="easyui-combobox" id="branchSchool" name="branchSchool" style="width:80px;"><option value="">请选择</option>
<option value="总校">总校</option>
<option value="挂靠">挂靠</option>
</select>
           &nbsp;准驾车型：<select class="easyui-combobox" id="licenseType" name="licenseType" style="width:80px;"><option value="">请选择</option>
<option value="C1">C1</option>
<option value="C2">C2</option>
</select> 
           &nbsp;<a href="javascript:void(0);" onclick="FindData();" class="easyui-linkbutton" iconCls="icon-search">查询</a>
           </div>
    </div>


        

</html>